#! /bin/sh
# 在本目录执行脚本
shDir=$(cd `dirname $0`; pwd)
cd ${shDir}

# 变量声明
. ../func/const.sh
. ../func/file.sh
## 应用程序配置所在目录
confSource="${bakConfDir}/${uzerName}"
## 配置文件使用ohmyzsh
echo -e '\e[34m配置zsh\e[0m'

# 排除目标目录的旧文件
mkFileOld "${homeDir}" '.zshrc'
mkFileOld "${homeDir}" '.zsh_history'
mkFileOld "${homeDir}" '.oh-my-zsh'
# mkFileOld "${homeDir}" '.zprofile'

# 创建软链接到 bakConfDir
## 链接应用配置文件
ln -sf "${confSource}/.zshrc" "${homeDir}/.zshrc"
## sh历史纪录
ln -sf "${confSource}/.zsh_history" "${homeDir}/.zsh_history"
## ohmyzsh配置文件
ln -sf "${confSource}/.oh-my-zsh" "${homeDir}/.oh-my-zsh"
## zsh环境变量
# ln -sf "${confSource}/.zprofile" "${homeDir}/.zprofile"

echo '将zsh设为默认shell'
chsh -s $(which zsh)

## 同步.oh-my-zsh
echo '更新ohmyzsh配置'
cd "${confSource}/.oh-my-zsh"
git remote set-url origin https://mirrors.cernet.edu.cn/ohmyzsh.git
git pull -q